package com.woniu.pojo;

import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * clazz
 * @author 
 */
public class Clazz implements Serializable {
    /**
     * 班中男生人数
     */
    private Integer boy;
private  User user;

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public Integer getBoy() {
        return boy;
    }

    public void setBoy(Integer boy) {
        this.boy = boy;
    }
    /**
     * 班中女生
     */
    private Integer gril;

    public Integer getGril() {
        return gril;
    }

    public void setGril(Integer gril) {
        this.gril = gril;
    }
    /**
     * 班中男生的比例
     */
    private double boyradio;

    public double getBoyradio() {
        return boyradio;
    }

    public void setBoyradio(double boyradio) {
        this.boyradio = boyradio;
    }

    /**
     * 班号
     */
    private Integer cid;

    /**
     * 班主任
     */
    private Integer uid;

    /**
     * 班级名字
     */
    private String cname;

    /**
     * 状态
     */
    private String cstate;

    /**
     * 开班时间
     */
    @DateTimeFormat(pattern="yyyy-MM-dd")
    @JsonFormat(pattern="yyyy-MM-dd", timezone="GMT+8")
    private Date begin;

    /**
     * 结课时间
     */
    @DateTimeFormat(pattern="yyyy-MM-dd")
    @JsonFormat(pattern="yyyy-MM-dd", timezone="GMT+8")
    private Date end;
    private String tname;

    public String getTname() {
        return tname;
    }

    public void setTname(String tname) {
        this.tname = tname;
    }

    private static final long serialVersionUID = 1L;

    public Integer getCid() {
        return cid;
    }

    public void setCid(Integer cid) {
        this.cid = cid;
    }

    public Integer getUid() {
        return uid;
    }

    public void setUid(Integer uid) {
        this.uid = uid;
    }

    public String getCname() {
        return cname;
    }

    public void setCname(String cname) {
        this.cname = cname;
    }

    public String getCstate() {
        return cstate;
    }

    public void setCstate(String cstate) {

        this.cstate = cstate;
    }

    public Date getBegin() {
        return begin;
    }

    public void setBegin(Date begin) {
        SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd");
        String dateStr=simpleDateFormat.format(begin);
        java.sql.Date sqlDate=null;

        long time = 0;
        try {
            time = simpleDateFormat.parse(dateStr).getTime();
        } catch (ParseException e) {
            e.printStackTrace();
        }
        sqlDate=new  java.sql.Date(time);

        this.begin = sqlDate;
    }

    public Date getEnd() {
        return end;
    }

    public void setEnd(Date end) {
        SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd");
        String dateStr=simpleDateFormat.format(end);
        java.sql.Date sqlDate=null;

        long time = 0;
        try {
            time = simpleDateFormat.parse(dateStr).getTime();
        } catch (ParseException e) {
            e.printStackTrace();
        }
        sqlDate=new  java.sql.Date(time);

        this.end = sqlDate;

    }

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        Clazz other = (Clazz) that;
        return (this.getCid() == null ? other.getCid() == null : this.getCid().equals(other.getCid()))
            && (this.getUid() == null ? other.getUid() == null : this.getUid().equals(other.getUid()))
            && (this.getCname() == null ? other.getCname() == null : this.getCname().equals(other.getCname()))
            && (this.getCstate() == null ? other.getCstate() == null : this.getCstate().equals(other.getCstate()))
            && (this.getBegin() == null ? other.getBegin() == null : this.getBegin().equals(other.getBegin()))
            && (this.getEnd() == null ? other.getEnd() == null : this.getEnd().equals(other.getEnd()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getCid() == null) ? 0 : getCid().hashCode());
        result = prime * result + ((getUid() == null) ? 0 : getUid().hashCode());
        result = prime * result + ((getCname() == null) ? 0 : getCname().hashCode());
        result = prime * result + ((getCstate() == null) ? 0 : getCstate().hashCode());
        result = prime * result + ((getBegin() == null) ? 0 : getBegin().hashCode());
        result = prime * result + ((getEnd() == null) ? 0 : getEnd().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", cid=").append(cid);
        sb.append(", uid=").append(uid);
        sb.append(", cname=").append(cname);
        sb.append(", cstate=").append(cstate);
        sb.append(", begin=").append(begin);
        sb.append(", end=").append(end);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}